package org.abc.fund.service.funds;

import org.abc.fund.entity.funds.FundHolding;
import org.abc.fund.repository.funds.FundHoldingRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class FundHoldingService {

    @Autowired
    private FundHoldingRepository fundHoldingRepository;

    public List<FundHolding> getHoldingsByFundCode(String fundCode) {
        return fundHoldingRepository.findByFundCodeOrderByHoldingRatioDesc(fundCode);
    }

    public FundHolding addHolding(FundHolding holding) {
        return fundHoldingRepository.save(holding);
    }

    public void deleteHolding(Long id) {
        fundHoldingRepository.deleteById(id);
    }
}
